#include <bits/stdc++.h>
// 2025/02/05
// tag: Binary Search Monotonic queue Dynalmic programming
// Author: Zhang Muen
using namespace std;

long long n, d, k, pos[500001], point[500001], dp[500001];

bool check(long long l, long long r)
{
    deque<long long> q;
    long long ans = 0, last = 0;
    memset(dp, -0x3f, sizeof(dp));
    dp[0] = 0;
    for (long long i = 1; i <= n; i++) {
        while (last < i && pos[i] - pos[last] >= l) {
            while (!q.empty() && dp[q.back()] <= dp[last])
                q.pop_back();
            q.push_back(last);
            last++;
        }
        while (!q.empty() && pos[i] - pos[q.front()] > r)
            q.pop_front();
        if (!q.empty())
            dp[i] = dp[q.front()] + point[i];
        ans = max(ans, dp[i]);
    }
    return ans >= k;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> d >> k;
    for (long long i = 1; i <= n; i++)
        cin >> pos[i] >> point[i];
    long long l = 0, r = 1e9;
    while (l <= r) {
        long long mid = (l + r) / 2;
        if (check(max(1LL, d - mid), d + mid))
            r = mid - 1;
        else
            l = mid + 1;
    }
    if (l > 1e9)
        cout << -1 << endl;
    else
        cout << l << endl;
    return 0;
}